#pragma once
#include <lcir/IR/Lambda.h>
#include <lcir/Dag2Dag/Pattern.h>
#include <lcir/IR/Op.h>

#include <map>
#include <memory>
#include <optional>
#include <vector>
namespace lcir {
	class D2DDriver {
		/**
		 * @brief 工作的lambda
		 */
		Lambda *lambda{nullptr};
		std::map<OpInstance*, std::vector<std::shared_ptr<Pattern>>> opInstanceToPatterns;
		Pattern* findPattern(OpInstance *op);
	public:
		D2DDriver(Lambda *lambda): lambda(lambda) {}
		void addPattern(std::shared_ptr<Pattern> pattern);
		template<class ...Pattern>
		void addPatterns() {
			(addPattern(std::make_shared<Pattern>()), ...);
		}
		void run();
	};
}